// 每隔一秒修改一次时钟
var now = new Date();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();

document.getElementById('hour').innerHTML = hour;
document.getElementById('minute').innerHTML = minute;
document.getElementById('second').innerHTML = second;

setInterval(function () {
    var now = new Date();
    var hour = now.getHours();
    var minute = now.getMinutes();
    var second = now.getSeconds();
    // 时间赋值到页面，时间小于10，前面补0;
    document.getElementById('hour').innerHTML = hour < 10 ? '0' + hour : hour;
    document.getElementById('minute').innerHTML = minute < 10 ? '0' + minute : minute;
    document.getElementById('second').innerHTML = second < 10 ? '0' + second : second;
},1000)